<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/3/19 0019
 * Time: 18:31
 */

namespace App\Http\Controllers\Admin;

use Illuminate\Support\Facades\Redis;

class TestRedisController
{
    public function rank(){
        Redis::zAdd('key', 1, 'val1');
        Redis::zAdd('key', 0, 'val0');
        Redis::zAdd('key', 5, 'val5');
        Redis::zAdd('key', 6, 'val2');
        Redis::zAdd('key', 2, 'val3');
        $resultArr = Redis::zrevRange ('key', 0, -1); // array(val0, val1, val5)
        echo "<pre>";
        echo '排行榜';
        var_dump($resultArr);
        echo '<br>val0的分数:';
        echo Redis::zScore('key','val0');
        echo '<br>val5的排行';
        echo  Redis::zrevRank ('key','val5');
        Redis::zIncrby('key',8,'val0');

        echo '<br>val0的分数:';
        echo Redis::zScore('key','val0');
        echo '<br>val0的排行';
        echo  Redis::zrevRank ('key','val0');
        return ;
    }
}